package com.pkk.cloud.support.gataway.spring.simple;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @description:
 * @author: peikunkun
 * @create: 2019-08-22 18:58
 **/
public class Simple {

  public static void main(String[] args) {
    for (int i = 0; i < 300; i++) {
//      String requestUrl = "http://localhost:8081/cloud-support-service/user/login?a=" + i;
      String requestUrl = "http://118.25.123.16:8081/cloud-support-service/user/login?a=" + i;
      final String post = HttpUtil.post(requestUrl, "");
      System.out.println(i + ":-:" + post);
    }
  }


  public static void main1(String[] args) {
    String[] strs = {"java8", "is", "easy", "to", "use"};
    List<String[]> distinctStrs = Arrays.stream(strs)
        .map(str -> str.split(""))  // 映射成为Stream<String[]>
        .distinct()
        .collect(Collectors.toList());
    System.out.println(JSONObject.toJSONString(distinctStrs));
    //在执行map操作以后，我们得到是一个包含多个字符串（构成一个字符串的字符数组）的流，此时执行distinct操作是基于在这些字符串数组之间的对比，所以达不到我们希望的目的，此时的输出为：

    List<String> distinctStrs1 = Arrays.stream(strs)
        .map(str -> str.split(""))  // 映射成为Stream<String[]>
        .flatMap(Arrays::stream)  // 扁平化为Stream<String>
        .distinct()
        .collect(Collectors.toList());
    System.out.println(JSONObject.toJSONString(distinctStrs1));

  }


}
